//
// afix_math.h
//

#ifndef _CHLDS_MATH_H_
#define _CHLDS_MATH_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef ZERO
#undef ZERO
#define ZERO            1.0e-12
#else
#define ZERO            1.0e-12
#endif // ZERO

#ifdef PI
#undef PI
#define PI              3.141592653589793238
#else
#define PI              3.141592653589793238
#endif // PI

#ifdef MAX
#undef MAX
#endif // MAX
#define MAX(a, b)       (((a) > (b)) ? (a) : (b))

#ifdef MIN
#undef MIN
#endif // MIN
#define MIN(a, b)       (((a) < (b)) ? (a) : (b))

#ifdef ABS
#undef ABS
#endif // ABS
#define ABS(x)          (((x) >= 0) ? (x) : (-(x)))

// complex type
typedef struct _TComplex
{
    float32 real;
    float32 imag;
} TComplex;

// base matrix type
typedef struct _TMatrixByte
{
    byte*   data;
    uint32  rows;
    uint32  cols;
} TMatrixByte;

typedef struct _TMatrixSint32
{
    sint32* data;
    uint32  rows;
    uint32  cols;
} TMatrixSint32;

typedef struct _TMatrixSint64
{
    sint64* data;
    uint32  rows;
    uint32  cols;
} TMatrixSint64;

typedef struct _TMatrixFloat32
{
    float32* data;
    uint32   rows;
    uint32   cols;
} TMatrixFloat32;

typedef struct _TMatrixFloat64
{
    float64* data;
    uint32   rows;
    uint32   cols;
} TMatrixFloat64;

typedef struct _TMatrixComplex
{
    TComplex* data;
    uint32    rows;
    uint32    cols;
} TMatrixComplex;

// base vector type
typedef struct _TVectorByte
{
    byte*   data;
    uint32  size;
} TVectorByte;

typedef struct _TVectorSint32
{
    sint32* data;
    uint32  size;
} TVectorSint32;

typedef struct _TVectorSint64
{
    sint64* data;
    uint32  size;
} TVectorSint64;

typedef struct _TVectorFloat32
{
    float32* data;
    uint32   size;
} TVectorFloat32;

typedef struct _TVectorFloat64
{
    float64* data;
    uint32   size;
} TVectorFloat64;

typedef struct _TVectorComplex
{
    TComplex* data;
    uint32   size;
} TVectorComplex;

#ifdef __cplusplus
}
#endif

#endif // _AFIX_MATH_H_
